<template>
  <div>

    <el-dialog
      v-if="dialogVisible"
      title="项目结题申请"
      :visible.sync="dialogVisible"
      width="700px"
      :before-close="handleClose">

      <el-form ref="form" :model="datas" :rules="rules" class="demo-form-inline" label-width="100px" size="medium" label-position="left">

        <el-form-item label="项目编号">
          <div>{{project.project_no}}</div>
        </el-form-item>

        <el-form-item label="项目名称">
          <div>{{project.project_name}}</div>
        </el-form-item>

        <el-form-item label="结题状态">
          <el-select v-model="datas.type" placeholder="请选择结题状态">
            <el-option
              label="完成验收"
              :value="1">
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="项目进度" prop="project_progress_des">
          <div class="textarea">
            <el-input
              placeholder="请输入项目进度"
              v-model="datas.project_progress_des"
              type="textarea"
              :rows="2">
            </el-input>
          </div>

        </el-form-item>

        <el-form-item label="项目结果" prop="project_result">
          <div class="textarea">
            <el-input
              v-model="datas.project_result"
              type="textarea"
              :rows="2">
            </el-input>
          </div>

        </el-form-item>

<!--        <el-form-item label="费用总计" prop="project_cost">-->
<!--          <div class="textarea">-->
<!--            <el-input-->
<!--              v-model="datas.project_cost"-->
<!--              type="textarea"-->
<!--              :rows="2">-->
<!--            </el-input>-->
<!--          </div>-->

<!--        </el-form-item>-->


      </el-form>

      <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="confirmClick">确 定</el-button>
        </span>
    </el-dialog>

  </div>
</template>

<script>
    export default {
        name: "projectEndDialog",
        data:function () {
            return{
                project:{},
                rules: {
                    project_progress_des: [
                        { required: true, message: '请输入项目进度', trigger: 'blur' }
                    ],
                    project_result: [
                        { required: true, message: '请输入结果', trigger: 'blur' }
                    ],
                    project_cost: [
                        { required: true, message: '请输入费用总计', trigger: 'blur' }
                    ],
                },
                datas:{
                    type:1,
                    project_progress_des:'',    //进度
                    project_result:'',          //原因
                    project_cost:'',            //费用
                },
                dialogVisible:false,
            }
        },
        methods:{
            handleClose:function () {
                this.dialogVisible = false;
            },
            confirmClick:function () {
                if (this.$refs.form){
                    this.$refs.form.validate((valid) => {
                        if (valid){
                            this.dialogVisible = false
                            this.$api.PROJECT_MANAGER_PROJECT_END_CHECK2(this.project.id,this.datas).then(res=>{
                                if (res.code == 200){
                                    this.$message.success("提交成功")
                                    this.$emit("update")
                                }else {
                                    this.$message.error(res.msg)
                                }
                            })
                        }
                    });
                }
            },
            showDialog:function (data) {
                this.project = data;
                this.datas = {
                    type:1,
                    project_progress_des:'',    //进度
                    project_result:'',          //原因
                    project_cost:'',            //费用
                }
                this.dialogVisible = true;

            }
        }
    }
</script>

<style scoped>

</style>
